package com.csu.tour.controller;

import com.csu.tour.entity.StarHotel;
import com.csu.tour.service.StarHotelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

// StarHotelController.java
@RestController
@RequestMapping("/star-hotels")
public class StarHotelController {

    @Autowired
    private StarHotelService starHotelService;

    @GetMapping("/{hotelId}/bookings")
    public ResponseEntity<?> getBookings(@PathVariable("hotelId") int hotelId,
                                         @RequestParam(defaultValue = "1") int page,
                                         @RequestParam(defaultValue = "10") int size) {
        try {
            List<StarHotel> starHotels = starHotelService.getStarHotelWithRooms(hotelId, page, size);
            return ResponseEntity.ok(starHotels);
        } catch (Exception e) {
            e.printStackTrace();
            return ResponseEntity.badRequest().body("Invalid request");
        }
    }
}
